﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TMC_CMS.Controllers;

namespace TMC_CMS.Utility
{
    public static class ControllerActionNameHelper
    {
        public static readonly string CONTROLLER_NAME_USER = "用户权限管理";
        public static readonly string CONTROLLER_NAME_VENDOR = "供应商基本信息";
        public static readonly string CONTROLLER_NAME_CONTRACT = "供应商合同信息";
        public static readonly string CONTROLLER_NAME_BASICDATA = "基础数据维护";

        public static readonly string CONTROLLER_ID_USER = "User";
        public static readonly string CONTROLLER_ID_VENDOR = "Vendor";
        public static readonly string CONTROLLER_ID_CONTRACT = "Contract";
        public static readonly string CONTROLLER_ID_BASICDATA = "BasicData";

        public static readonly string USER_ACTION_INDEX_NAME = "用户列表";
        public static readonly string USER_ACTION_ADD_NAME = "添加用户";
        public static readonly string USER_ACTION_EDIT_NAME = "修改用户";

        public static readonly string VENDOR_ACTION_INDEX_NAME = "供应商列表";

        public enum ControllerType
        {
            USER,
            VENDOR,
            CONTRACT,
            BASICDATA
        }

        public static ControllerType GetControllerType(ControllerBase controller)
        {
            if (controller is UserController)
            {
                return ControllerType.USER;
            }
            else if (controller is ContractController)
            {
                return ControllerType.CONTRACT;
            }
            else if (controller is BasicDataController)
            {
                return ControllerType.BASICDATA;
            }
            else if (controller is VendorController)
            {
                return ControllerType.VENDOR;
            }
            else
            {
                return ControllerType.VENDOR;
            }
        }

        public static string GetControllerName(ControllerType currentController)
        {
            switch (currentController)
            {
                case ControllerType.USER:
                    return CONTROLLER_NAME_USER;
                case ControllerType.CONTRACT:
                    return CONTROLLER_NAME_CONTRACT;
                case ControllerType.BASICDATA:
                    return CONTROLLER_ID_BASICDATA;
                case ControllerType.VENDOR:
                default:
                    return CONTROLLER_NAME_VENDOR;
            }
        }

        public static string GetControllerID(ControllerType currentController)
        {
            switch (currentController)
            {
                case ControllerType.USER:
                    return CONTROLLER_ID_USER;
                case ControllerType.CONTRACT:
                    return CONTROLLER_ID_CONTRACT;
                case ControllerType.BASICDATA:
                    return CONTROLLER_ID_BASICDATA;
                case ControllerType.VENDOR:
                default:
                    return CONTROLLER_ID_VENDOR;
            }
        }

        public static string GetActiveClass(ControllerType currentController, ControllerType targetController)
        {
            if (currentController == targetController)
            {
                return "class=\"active\"";
            }
            return string.Empty;
        }
    }
}

